import { reactive ,onMounted, toRefs} from "vue";
import axios from 'axios'
import { useRoute } from "vue-router";
const HttpHooks =()=>{
    const Route =useRoute()
    const state =reactive({
        movies:[]
    })
    onMounted(()=>{
        let path= Route.path.replace("films","movie")
        // console.log(path.replace("films","movie"));
        axios.get(`http://122.112.161.135:4000/api${path}`).then(res=>{
            state.movies =res.data.res
        })
    })
    const refState =toRefs(state);
    return refState
}

export default HttpHooks